package cn.talkimages.web.admin.actions.photographer;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.talkimages.framework.utils.string.StringUtil;
import cn.talkimages.web.beans.PhotographerBean;

public class PhotographerAPIAction extends PhotographerAction {

	private static final long serialVersionUID = -6597968078098494270L;

	private static final Log LOG = LogFactory
			.getLog(PhotographerAPIAction.class);

	private String brandId;

	private List<PhotographerBean> photographers;

	/**
	 * 取得所属品牌的摄影师信息
	 * 
	 * @throws Exception
	 */
	public String queryPhotographersInBrand() throws Exception {

		if (StringUtil.isBlank(brandId) || !StringUtil.isNumeric(brandId)) {
			LOG.error("request brand_id[" + String.valueOf(brandId)
					+ "] is not valid.");
			return ERROR;
		}

		photographers = getPhotographerService().getPhotographersByBrandId(
				Long.parseLong(brandId));
		
		getHttpServletRequest().setAttribute("reqPhotographers", photographers);
		
		return SUCCESS;
	}

	// ----------------------- Getter & Setter ----------------------- //

	public String getBrandId() {
		return brandId;
	}

	public void setBrandId(String brandId) {
		this.brandId = brandId;
	}

	public List<PhotographerBean> getPhotographers() {
		return photographers;
	}

	public void setPhotographers(List<PhotographerBean> photographers) {
		this.photographers = photographers;
	}
}
